//
// Created by mio on 25-5-19.
//

#ifndef H264DECODER_H
#define H264DECODER_H

#include <QThread>
#include <atomic>

#include "AV_Common.h"


class VideoConvert;

class H264Decoder : public QThread ,public DecodBase
{
    Q_OBJECT
public:
    H264Decoder(AVContext* ac,QObject* parent = nullptr);
    ~H264Decoder();
    int  Open(const AVCodecParameters* codecParamer);

    inline bool isFull(){return video_queue_.size() > 10;}
    inline void put_packet(const AVPacketPtr packet){video_queue_.push(packet);}

protected:
    void Close();
    void run() override;
private:
    std::atomic_bool quit_ = false;
    AVFramePtr yuv_frame_ = nullptr;
    AVQueue<AVPacketPtr> video_queue_;
    AVContext*    avContext_ = nullptr;         // 解码队列是AVPlayer管理的, 通过AVDEMuxer传递的
    std::unique_ptr<VideoConvert> videoConver_;

};

#endif //H264DECODER_H